
import java.util.concurrent.Callable;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.FutureTask;

public class ThreaTest {

    public static void main(String[] args) {
        Thread t = new MyThread();
        t.start();

        Thread t2 = new Thread(new MyRunnable());
        t2.start();

        FutureTask<Integer> task = new FutureTask<>(new MyCallable());
        Thread t3 = new Thread(task);
        t3.start();
        try {
            task.get();
        } catch (InterruptedException e) {
            throw new RuntimeException(e);
        } catch (ExecutionException e) {
            throw new RuntimeException(e);
        }


    }

}


// 1.继承 Thread 重写 run() 使用start启动线程
class MyThread extends Thread {

    public void run() {
        System.out.println("我是MyThread线程");
    }
}

// 2. 实现 Runnable 接口，重写run 构建Thread对象，使用start启动
class MyRunnable implements Runnable {

    @Override
    public void run() {

    }
}

// 3. 实现 Callable 接口，重写 call 方法，构建 FutureTask（ Runnable 的实现类） 对象，使用start启动
class MyCallable implements Callable<Integer> {

    @Override
    public Integer call() throws Exception {
        return null;
    }
}